home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************
- *
- * MODULE NAME: CPICERR.H
- *
- * COPYRIGHTS:
- * This module contains code made available by IBM
- * Corporation on an AS IS basis. Any one receiving the
- * module is considered to be licensed under IBM copyrights
- * to use the IBM-provided source code in any way he or she
- * deems fit, including copying it, compiling it, modifying
- * it, and redistributing it, with or without
- * modifications. No license under any IBM patents or
- * patent applications is to be implied from this copyright
- * license.
- *
- * A user of the module should understand that IBM cannot
- * provide technical support for the module and will not be
- * responsible for any consequences of use of the program.
- *
- * Any notices, including this one, are not to be removed
- * from the module without the prior written consent of
- * IBM.
- *
- * AUTHOR: Peter J. Schwaller
- * VNET: PJS at RALVM6 Tie Line: 444-4376
- * Internet: pjs@ralvm6.vnet.ibm.com (919) 254-4376
- * John Q. Walker
- * VNET: JOHNQ at RALVM6 Tie Line: 444-4414
- * Internet: johnq@ralvm6.vnet.ibm.com (919) 254-4414
- *
- * AVAILABILITY:
- * These sample programs and source are also available on
- * CompuServe through the APPC Information Exchange. To get
- * to the APPC forum just type 'GO APPC' from any CompuServe
- * prompt. The samples are available in the Sample Programs
- * library section. Just search on the keyword CPICPGMS to
- * find all the samples in this series.
- *
- * Updates for the sample programs and support for many more
- * CPI-C platforms will also be made available on CompuServe.
- *
- * RELATED FILES:
- * Use CPICERR.C
- *
- *****************************************************************************/
-
- /*****************************************************************************
- *
- * OVERVIEW OF CPICERR CALLS
- *
- * cpicerr_new() Creates a CPICERR object.
- * This must be done before any other
- * cpicerr calls can be used.
- *
- * These calls set values in the cpicerr object structure and affect how
- * cpicerr_handle_rc reacts to errors.
- *
- * cpicerr_set_log_file_name() What filename to use for logging
- * cpicerr_set_log_file_path() Where the filename is
- * cpicerr_set_program_name() String - Output as part of log info
- * cpicerr_set_program_info() String - Output as part of log info
- * cpicerr_set_major_version() 8 bit int - see cpicerr_exchange_version
- * cpicerr_set_minor_version() 8 bit int - see cpicerr_exchange_version
- * cpicerr_set_conv_id() Used to extract conversation state info
- * cpicerr_set_exit_level() Level of error on which to exit
- * cpicerr_set_show_level() Level of error on which to show errors
- * cpicerr_set_log_level() Level of error on which to log errors
- *
- * cpicerr_handle_rc() Should be called by the program for all
- * UNEXPECTED return codes.
- * Functions performed are:
- * Classification of the return code
- * Showing partial info to end user
- * Logging complete info to disk
- *
- * cpicerr_destroy() Destroys the CPICERR object.
- *
- *
- * cpicerr_classify_rc() These are internal calls used by
- * cpicerr_show_rc() other cpicerr_handle_rc.
- * cpicerr_log_cpicerr()
- * cpicerr_get_message()
- * cpicerr_free_cpicerr()
- * cpicerr_set_rc_info()
- * cpicerr_show_product_info()
- *
- *****************************************************************************/
-
- #ifndef INCL_CPICERR
- #define INCL_CPICERR
-
- /*
- * Collection of routines with special ported version for each platform
- * The only thing that is used from CPICPORT.H is the correct setting
- * of the SHORT_IDENTIFIERS and TIME_NOT_SUPPORTED identifiers.
- */
- #include "cpicport.h"
-
- #if defined(SHORT_IDENTIFIERS)
- /*
- * The C/370 compiler requires that identifier be unique in the 1st 8 chars.
- * If any new functions are added to this file, they should also be added to
- * this list, with a unique mapping.
- */
- #define cpicerr_classify_rc cecr
- #define cpicerr_destroy cedestroy
- #define cpicerr_free_cpicerr ceff
- #define cpicerr_get_message cegm
- #define cpicerr_handle_rc cehr
- #define cpicerr_new cenew
- #define cpicerr_log_cpicerr celf
- #define cpicerr_set_conv_id cesci
- #define cpicerr_set_exit_level cesxl
- #define cpicerr_set_log_file_name ceslfn
- #define cpicerr_set_log_file_path ceslfp
- #define cpicerr_set_log_level cesll
- #define cpicerr_set_program_info cespi
- #define cpicerr_set_program_name cespn
- #define cpicerr_set_minor_version ceminor
- #define cpicerr_set_major_version cemajor
- #define cpicerr_set_rc_info cesetr
- #define cpicerr_set_show_level cessl
- #define cpicerr_show_product_info cespri
- #define cpicerr_show_rc cesr
- #define cpicerr_verbs_short cvshort
- #define cpicerr_verbs_long cvlong
- #define cpicerr_return_codes cerc
- #define cpicerr_rc_classes cercclass
- #define cpicerr_states_conv cestate
- #define cpicerr_conv_types ceconv_type
- #define cpicerr_sync_levels cesync
- #define cpicerr_exchange_version ceev
- #endif
-
- #ifndef TIME_NOT_SUPPORTED
- /* Needed for the time_t structure used within the CPICINIT structure */
- #include <time.h>
- #endif
-
- /*
- * Specify the maximum sizes for a variety of CPI-C fields.
- * The +1 is added to allow room for the C null terminator for strings.
- */
- #define MAX_LU_ALIAS (8+1)
- #define MAX_PLU_ALIAS (8+1)
- #define MAX_TP_NAME (64+1)
- #define MAX_SYM_DEST_NAME (8+1)
- #define MAX_FQPLU_NAME (17+1)
- #define MAX_DESTINATION (17+1)
- #define MAX_MODE_NAME (8+1)
- #define MAX_USERID (8+1)
- #define MAX_PASSWD (8+1)
-
- /*****************************************************************************
- * These values are used to break the CPI-C return codes down into classes.
- * They are organized from errors that can be ignored, to fatal errors
- * which cannot be recovered from.
- *
- * The values ALL_ERRORS and NO_ERRORS are used as extremes for the
- * cpicerr_set_exit_level() and cpicerr_set_show_level() calls, and are
- * not actual classification values.
- *****************************************************************************/
- typedef enum {
- RC_OK = 0,
- ALL_ERRORS,
- CONTINUE ,
- RETRY_VERB ,
- SECURITY_NOT_VALID,
- ERROR_RECEIVED ,
- RETRY_CONV ,
- RETRY_CONV_BO ,
- BACKOUT_RECEIVED ,
- UNRECOVERABLE ,
- UNRECOVERABLE_BO ,
- NO_ERRORS
- } CPIC_RC_HANDLING;
-
- /*
- * Since CPI-C does not provide actual values that correspond to each CPI-C
- * call, we have to invent our own so that we can put the call names into
- * our message lists.
- */
- typedef enum {
- MSG_CMACCP,
- MSG_CMALLC,
- MSG_CMCFM ,
- MSG_CMCFMD,
- MSG_CMDEAL,
- MSG_CMECS ,
- MSG_CMECT ,
- MSG_CMEMN ,
- MSG_CMEPLN,
- MSG_CMESL ,
- MSG_CMFLUS,
- MSG_CMINIT,
- MSG_CMPTR ,
- MSG_CMRCV ,
- MSG_CMRTS ,
- MSG_CMSCT ,
- MSG_CMSDT ,
- MSG_CMSED ,
- MSG_CMSEND,
- MSG_CMSERR,
- MSG_CMSF ,
- MSG_CMSLD ,
- MSG_CMSMN ,
- MSG_CMSPLN,
- MSG_CMSPTR,
- MSG_CMSRC ,
- MSG_CMSRT ,
- MSG_CMSSL ,
- MSG_CMSST ,
- MSG_CMSTPN,
- MSG_CMTRTS,
- MSG_XCSCSU,
- MSG_XCSCST,
- MSG_XCSCSP
- } CPIC_VERB_INDEX;
-
- /*****************************************************************************
- * This structure contains all of the information necessary to for all
- * cpicerr calls. All of the fields which need to be changed by the
- * application program should be modified through the cpicerr_set...()
- * calls. The application program should never have to access the
- * cpicerr structure directly.
- *
- * When an unexpected return code occurs, this structure is used to
- * determine what error processing should occur, including:
- * display of minimal error information
- * logging of complete error information
- * where to log the data
- *
- * If a field is added to this structure, be sure to add the correct
- * initialization values for the field in the cpicerr_new() function.
- *****************************************************************************/
-
- typedef struct error_handler_cpicerr {
- char * program_name; /* program's name */
- char * program_info; /* program information */
- CPIC_VERB_INDEX verb_index; /* index of the failing verb */
- CM_RETURN_CODE conv_rc; /* return code from CPI-C */
- CM_INT32 mode_name_length; /* mode_name length */
- CM_INT32 partner_LU_name_length; /* partner_LU_name length */
- CM_CONVERSATION_STATE conversation_state;
- CM_CONVERSATION_TYPE conversation_type;
- CM_SYNC_LEVEL sync_level;
- char * log_file_path; /* path for the log file */
- char * log_file_name; /* where to log errors */
- unsigned char conversation_id[8]; /* CPI-C Conversation ID */
- int conv_id_set; /* Was conv_id set? */
- unsigned char mode_name[MAX_MODE_NAME]; /* mode_name */
- unsigned char partner_LU_name[MAX_FQPLU_NAME]; /* partner_LU_name */
- CPIC_RC_HANDLING exit_level; /* should we exit on an error? */
- CPIC_RC_HANDLING show_level; /* should we show errors? */
- CPIC_RC_HANDLING log_level; /* should we log errors? */
- char major_version; /* Major version number */
- char minor_version; /* Minor version number */
- #ifndef TIME_NOT_SUPPORTED
- time_t program_start_time; /* time of cpicerr init */
- time_t program_error_time; /* time of error report */
- #endif
- } CPICERR;
-
-
- /*****************************************************************************
- * The following are the structures and constants used for handling all of
- * message strings in CPICERR.
- *****************************************************************************/
-
- /*
- * The cpicerr_message structure contains an index and the text message
- * associated with that index. In most cases, the index will be an actual
- * CPI-C return value. For example,
- * index = CM_SEND_STATE, message = "Send state"
- */
- typedef struct cpicerr_message {
- CM_INT32 index;
- char * message;
- } CPICERR_MESSAGE;
-
- /*
- * Each of the following is a list of messages, which are actually defined
- * in the CPICERR.C file. The messages are grouped together. For example,
- * all of the return code messages are in the cpicerr_return_codes list.
- */
- extern CPICERR_MESSAGE cpicerr_verbs_short[];
- extern CPICERR_MESSAGE cpicerr_verbs_long[];
- extern CPICERR_MESSAGE cpicerr_return_codes[];
- extern CPICERR_MESSAGE cpicerr_rc_classes[];
- extern CPICERR_MESSAGE cpicerr_states_conv[];
- extern CPICERR_MESSAGE cpicerr_conv_types[];
- extern CPICERR_MESSAGE cpicerr_sync_levels[];
-
- /*
- * This enum gives each list a label and a value to make it easier to
- * process all of the lists.
- */
- typedef enum cpicerr_message_type {
- CPIC_SYNC_LEVELS = 1,
- CPIC_CONV_TYPES = 2,
- CPIC_STATES_CONV = 3,
- CPIC_RC_CLASSES = 4,
- CPIC_RETURN_CODES = 5,
- CPIC_VERBS_SHORT = 6,
- CPIC_VERBS_LONG = 7
- } CPICERR_MESSAGE_TYPE;
-
- /*
- * The CPICERR_MESSAGE_LIST structure is what actually ties a
- * CPICERR_MESSAGE_TYPE value to the CPICERR_MESSAGE list that it relates
- * to. A table is defined in CPICERR.C that allows the cpicerr_get_message
- * routine to correlate a message label to its corresponding message list.
- */
- typedef struct cpicerr_message_list {
- CPICERR_MESSAGE_TYPE type;
- CPICERR_MESSAGE * list;
- } CPICERR_MESSAGE_LIST;
-
- /*
- * The following value is used to mark the end of CPICERR_MESSAGE lists.
- */
- #define MAX_MESSAGE 32767
-
-
-
-
-
-
-
- /*
- * If these CPI-C calls are not supported, these values will be returned
- * instead of a valid CPI-C values. In the message tables, the values
- * below will result in a message of "XXX not supported". This allows
- * us to differentiate between a call not being available on a platform,
- * and an unrecognized value returned on a call.
- */
- #define CMECS_NOT_SUPPORTED (CM_CONVERSATION_STATE) 99
- #define CMECT_NOT_SUPPORTED (CM_CONVERSATION_TYPE) 99
-
-
-
- /*
- * Used by the cpicerr_exchange_version() routine. Future flows may
- * be prefaced with new "command values" taken from this list.
- */
- typedef enum cpicerr_command {
- CPICERR_EXCHANGE_VERSION = 1
- } CPICERR_COMMAND;
-
- /*****************************************************************************
- * Function prototypes for routines that can be called via an application
- * program. See CPICERR.C for a full description of each function and
- * how to use it.
- *****************************************************************************/
- CPICERR *
- cpicerr_new(void);
-
- int cpicerr_set_program_name( CPICERR * cpicerr,
- char * program_name);
- int cpicerr_set_program_info( CPICERR * cpicerr,
- char * program_info);
- int cpicerr_set_major_version(CPICERR * cpicerr,
- char major_version);
- int cpicerr_set_minor_version(CPICERR * cpicerr,
- char minor_version);
- int cpicerr_set_conv_id( CPICERR * cpicerr,
- unsigned char * cm_conv_id);
- int cpicerr_set_log_file_name(CPICERR * cpicerr,
- char * log_file_name);
- int cpicerr_set_log_file_path(CPICERR * cpicerr,
- char * log_file_path);
- int cpicerr_set_exit_level( CPICERR * cpicerr,
- CPIC_RC_HANDLING exit_level);
- int cpicerr_set_show_level( CPICERR * cpicerr,
- CPIC_RC_HANDLING show_level);
- int cpicerr_set_log_level( CPICERR * cpicerr,
- CPIC_RC_HANDLING log_level);
- CPIC_RC_HANDLING
- cpicerr_handle_rc( CPICERR * cpicerr,
- CPIC_VERB_INDEX verb_index,
- CM_RETURN_CODE conv_rc);
- int cpicerr_exchange_version( CPICERR * cpicerr,
- unsigned char * cm_conv_id,
- CM_INT32 conv_state,
- char * partner_major_version,
- char * partner_minor_version);
- void cpicerr_destroy( CPICERR * cpicerr);
-
-
- /*****************************************************************************
- * Function prototypes for internal routines. In general, these should
- * not be called directly by an application program.
- *****************************************************************************/
- void cpicerr_classify_rc( CM_RETURN_CODE conv_rc,
- CPIC_RC_HANDLING * classification);
- void cpicerr_show_rc( CPICERR * cpicerr,
- FILE * target_file);
- int cpicerr_log_cpicerr( CPICERR * cpicerr);
- char * cpicerr_get_message( CPICERR_MESSAGE_TYPE message_type,
- CM_INT32 index);
- void cpicerr_free_cpicerr( CPICERR * cpicerr);
- void cpicerr_set_rc_info( CPICERR * cpicerr,
- CPIC_VERB_INDEX verb_index,
- CM_RETURN_CODE conv_rc);
- void cpicerr_show_product_info(CPICERR * cpicerr,
- FILE * target_file);
-
- /*****************************************************************************
- * The following function prototypes and macros are used only by the
- * OS/2 specific code used to obtain the sense data after an
- * allocation failure. They are not necessary, if GET_OS2_SENSE_DATA
- * has not been externally defined (with the -D compile flag).
- *****************************************************************************/
- #ifdef GET_OS2_SENSE_DATA
- cpicerr_os2_appc_allocate( CPICERR * cpicerr,
- FILE * target_file);
-
- USHORT
- parse_destination(char * in_string,
- char * plu_alias,
- char * fqplu_name);
-
-
-
-
- /* Macro BLANK_STRING sets string to all blanks */
- #define BLANK_STRING(str) memset(str,(int)' ',sizeof(str))
-
- #undef CLEAR_VCB
- /* Macro CLEAR_VCB sets the APPC verb control block to zeros */
- #define CLEAR_VCB(vcb) memset((char *)&vcb,(int)'\0',sizeof(vcb))
-
- /* convert a string to uppercase, up to length specified */
- #define TOUPPER_STRING(str,length) \
- {int i; for (i=0;i < length;i ++) \
- {str[i] = (char)toupper(str[i]);}}
-
- /* convert an ASCII blank padded string to an ASCIIZ string without pads */
- #define SNA2STRING(outstr, instr, max_length) \
- {int i; for (i=0;i < max_length && instr[i] != ' ';i ++) \
- {outstr[i] = instr[i];} outstr[i] = '\0';}
-
- #endif
-
- #endif